package com.example.project.controller;


import com.example.project.entity.Menu;
import com.example.project.service.IMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 作者：金照富
 * 2023年11月4日
 */
@RestController
@Api
public class MenuController {
    @Autowired
    private IMenuService menuService;

    @ApiOperation(value = "添加菜单")
    @RequestMapping("/insertMenu")
    public int insertMenu(Menu menu){
        return menuService.insertMenu(menu);
    }

    @ApiOperation(value = "删除菜单")
    @RequestMapping("/deleteMenu")
    public int deleteMenu(int id){
        Menu menu=new Menu();
        menu.setMenuId(id);
        return menuService.deleteMenu(menu);
    }

    @ApiOperation(value = "修改菜单")
    @RequestMapping("/updateMenu")
    public int updateMenu(Menu menu){
        return menuService.updateMenu(menu);
    }

    @ApiOperation(value = "查询所有菜单")
    @RequestMapping("/getAllMenu")
    public List<Menu> getAllMenu(Menu menu){
        return menuService.getAllMenu(menu);
    }

    @ApiOperation(value = "查询菜单")
    @RequestMapping("/getMenu")
    public Menu getMenu(int id){
        Menu menu=new Menu();
        menu.setMenuId(id);
        return menuService.getMenu(menu);
    }
}